{include file="public/header" /}
{load href="__PLUGINS__bootstrap/bootstrap-table.min.css"}
{load href="__PLUGINS__bootstrap/bootstrap-table.min.js"}
<style type="text/css">
  #des, #des input {
    width: 40px;
    text-align: center;
  }
  #id {
    width: 78px;
  }
  .bs-checkbox {
    width: 36px;
    height: 40px
  }
  .fixed-table-toolbar .columns, .fixed-table-toolbar .search {
    margin-left: 0px;
    margin-top: 0px
  }
  #title span {
    float: right;
    margin-left: 3.333px;
  }
  .search {
    margin-bottom: 0px !important;
  }
  .asdlkjasd {
    background: #1ab394;
    color: #fff
  }
  #title {
    position: relative;
    padding-right: 50px;
  }
  #title span {
    position: absolute;
    top: 12px;
    right: 10px;
  }
</style>
<body class="gray-bg">
<div class="wrapper wrapper-content {:config('adminClass.main')}">
  <div class="ibox float-e-margins">
    {include file="public/tophead"}
    {include file="public/top" /}
    <div class="ibox-content">
      {include file="public/topsection"}
      <div class="row row-lg">
        <div class="col-sm-12">
          <div class="fixed-table-toolbar">
              <a class="btn btn-default btn-outline {notpresent name='paystate'}asdlkjasd{/notpresent}" href="{:url('orders')}{present name='status'}/status/{$status}{/present}">全部</a>
              <a class="btn btn-default btn-outline {present name='paystate'}{eq name='paystate' value='0'}asdlkjasd{/eq}{/present}" href="{:url('orders',['paystate' => 0])}{present name='status'}/status/{$status}{/present}">待支付</a>
              <a class="btn btn-default btn-outline {present name='paystate'}{eq name='paystate' value='1'}asdlkjasd{/eq}{/present}" href="{:url('orders',['paystate' => 1])}{present name='status'}/status/{$status}{/present}">已支付</a>
              <a class="btn btn-default btn-outline {present name='paystate'}{eq name='paystate' value='-1'}asdlkjasd{/eq}{/present}" href="{:url('orders',['paystate' => -1])}{present name='status'}/status/{$status}{/present}">已失效</a>
          </div>
          <div class="fixed-table-toolbar">
              <a class="btn btn-default btn-outline {notpresent name='status'}asdlkjasd{/notpresent}" href="{:url('orders')}{present name='paystate'}/paystate/{$paystate}{/present}">全部</a>
              <a class="btn btn-default btn-outline {present name='status'}{eq name='status' value='0'}asdlkjasd{/eq}{/present}" href="{:url('orders',['status' => 0])}{present name='paystate'}/paystate/{$paystate}{/present}">待使用</a>
              <a class="btn btn-default btn-outline {present name='status'}{eq name='status' value='1'}asdlkjasd{/eq}{/present}" href="{:url('orders',['status' => 1])}{present name='paystate'}/paystate/{$paystate}{/present}">已使用</a>
              <a class="btn btn-default btn-outline {present name='status'}{eq name='status' value='-1'}asdlkjasd{/eq}{/present}" href="{:url('orders',['status' => -1])}{present name='paystate'}/paystate/{$paystate}{/present}">已失效</a>
          </div>
          <div class="fixed-table-toolbar">
            <form  method="get" action="">
              <div class="pull-left search">
                {php}
                if(input('?param.name')){
                {/php}
                <div class="pull-right search">
                  <a class="btn btn-w-m btn-link" href="{:url('orders')}">返回地址管理</a>
                </div>{php}
                }
                {/php}
                <div class="columns columns-right btn-group pull-left" >
                  <select class="form-control" name="search">
                    <option value="user_id">用户ID</option>
                    <option value="address_id" {present name='search'}{eq name='search' value='address_id'}selected{/eq}{/present}>地址ID</option>
                    <option value="number" {present name='search'}{eq name='search' value='number'}selected{/eq}{/present}>订单号</option>
                    <option value="name" {present name='search'}{eq name='search' value='name'}selected{/eq}{/present}>名称</option>
                  </select>
                </div>


                <div class="pull-right search" style="display: flex;">
                  <input name="start" type="text" id="start" class="form-control layui-input" value="{present name='start'}{$start}{/present}" placeholder=" # 起始时间" autocomplete="off" style="height:34px;width:180px;margin:0 10px;">
                  <input name="end" type="text" id="end" class="form-control layui-input" value="{present name='end'}{$end}{/present}" placeholder=" # 结束时间" autocomplete="off" style="height:34px;width:180px;margin:0 10px;">
                </div>


                <div class="pull-right search">
                  <button style="border-radius:0px; border:1px solid #e5e6e7; border-left:0px" class="btn btn-default btn-outline" type="submit">搜索</button>
                </div>
                <div class="pull-right search">
                  <input class="form-control input-outline" id="filter" type="text"
                         {php}
                         if(input('?param.name')){
                  if(input('param.name')){
                  echo "value='".input('name')."'";
                  }

                  }
                  {/php}
                  name="name" placeholder="">
                </div>


              </div>
            </form>
          </div>

          <div style="display:block;clear: both;"></div>

          <div class="example">
            <form class="form-horizontal" method="post">
              <table data-toggle="table">
                <thead>
                <tr>
                  <th>id</th>
                  <th>店铺</th>
                  <th>下单用户</th>
                  <th>商品名称</th>
                  <th>商品封面</th>
                  <th>价格(元)</th>
                  <th>使用状态</th>
                  <th>支付状态</th>
                  <th>可用时间</th>
                  <th>支付单号</th>
                  <th>支付时间</th>
                  <th>使用时间</th>
                  <th>其他信息</th>
                </tr>
                </thead>
                <tbody id="form">
                {volist name="data" id="v"}
                <tr id="id{$v.id}" class="class">
                  <td>{$v.id}</td>
                  <td>
                    <a onclick="address('{$v.address_id}')" style="color:#40BCF7">{$v.addname}</a>
                  </td>
                  <td>
                    <a onclick="member('{$v.user_id}')" style="color:#40BCF7">{$v.username}({$v.user_id})</a>
                  </td>
                  <td id="name">{$v.name}</td>
                  <td>
                    {notempty name="v.image"}
                      <a href="__ROOT__{$v.image}" target="_blank">
                          <img style="width:40px;height:40px;" src="__ROOT__{$v.image}"/>
                      </a>
                      {/notempty}
                  </td>
                  <td>{$v.price} 
                  </td>
                  <td>
                      <?php
                      if($v['status'] == 1){
                        echo "<span class='btn btn-primary btn-xs'>已使用</span>";
                      }elseif($v['status'] == 0){
                        echo "<span class='btn btn-danger btn-xs'>待使用</span>";
                      }else{
                        echo "<span class='btn btn-default btn-xs'>已失效</span>";
                      }
                      ?>
                  </td>
                  <td>
                      <?php
                      if($v['paystate'] == 1){
                        echo "<span class='btn btn-primary btn-xs'>已支付</span>";
                      }elseif($v['paystate'] == 0){
                        echo "<span class='btn btn-danger btn-xs'>待支付</span>";
                      }else{
                        echo "<span class='btn btn-default btn-xs'>已失效</span>";
                      }
                      ?>
                  </td>
                  <td>{$v.use_time}</td>
                  <td>{$v.number}</td>
                  <td><span {php}if(date('Ymd')==date('Ymd',$v['expire_time']))echo 'style="color: #ed5565"';{/php}>{$v.expire_time|date='Y-m-d H:i:s',###}</span></td>
                  <td>
                    {if condition="$v.create_time != $v.update_time"}
                    <span {php}if(date('Ymd')==date('Ymd',$v['update_time']))echo 'style="color: #ed5565"';{/php}>{$v.update_time|date='Y-m-d H:i:s',###}</span>
                    {else}
                    未使用
                    {/if}
                  </td>
                  <td><a onclick="info('{$v.id}')">查看</a></td>
                </tr>
                {/volist}
                </tbody>
              </table>
            </form>
          </div>
        </div>
      </div>
      <hr>
      <div class="row row-lg">
        <div class="col-sm-12 pages">{$page}</div>
      </div>
    </div>
  </div>
</div>
{include file="public/footer" /}
<script type="text/javascript">
  $(document).ready(function(){
    layui.use(['laydate'], function(){
        var laydate = layui.laydate;

        laydate.render({
            elem: '#start' //指定元素
            ,type: 'datetime'
            ,trigger: 'click'
        });

        laydate.render({
            elem: '#end' //指定元素
            ,type: 'datetime'
            ,trigger: 'click'
        });
    })
  });
  function address(id)
  {
      layui.use('layer', function(){
          var layer = layui.layer;
          layer.open({
              title :'预览',
              area: ['100%', '100%'],
              type: 2,
              content: '{:url("address/claim")}?search=id&name='+id
          });
      });
  }
  function member(id)
  {
      layui.use('layer', function(){
          var layer = layui.layer;
          layer.open({
              title :'预览',
              area: ['100%', '100%'],
              type: 2,
              content: '{:url("member/index")}?search=id&name='+id
          });
      });
  }
  function info(id)
  {
      layui.use('layer', function(){
          var layer = layui.layer;
          layer.open({
              title :'预览',
              area: ['100%', '100%'],
              type: 2,
              content: '{:url("orderinfo")}?id='+id
          });
      });
  }
  function watch(content) {
    layui.use('layer', function(){
      var layer = layui.layer;
      layer.open({
          title :'预览',
          area: ['100%', '100%'],
          type: 1,
          content: content
        });
    });
  }
</script>
